import request from '@/utils/request';
import { HttpCode } from '@/utils/contacts';

// 获取登陆人基础信息
export async function getPersonInfoByToken() {
  return request('/user/person/getPersonInfoByToken');
}

// 修改用户基本信息
export async function updatePersonInfo(params) {
  return request('/user/person/updatePersonInfo', {
    method: 'POST',
    requestType: 'form',
    data: params,
  });
}

// 获取手机验证码
export async function getverificationCode(params) {
  return request('/user/verificationCode/getVerificationCode', {
    method: 'POST',
    data: params,
  });
}

// 手机验证码认证
export async function SetverificationCode(params) {
  return request('/user/verificationCode/verificationCodeVerify', {
    method: 'POST',
    data: params,
  });
}

// 修改密码
export async function updatePassword(params) {
  return request('/user/user/updatePassword', {
    method: 'POST',
    data: params,
  });
}

// 重置密码
export async function SetPassword(params) {
  return request('/user/user/resetPwd', {
    method: 'POST',
    data: params,
  });
}

// 资质信息查询
export async function queryFlairList(data) {
  return request('/user/user/drive/queryFlairList', {
    method: 'post',
    data,
  });
}

// 资质信息编辑
export async function updateFlair(data) {
  return request('/user/user/drive/updateFlair', {
    method: 'post',
    data,
  });
}

// 根据用户id查看角色详情
export async function findRoleByUserId(userId) {
  return request(`/power/role/findRoleByUserId/${userId}`, {
    method: 'GET',
  });
}

// 获取应用图标
export async function getIconfont() {
  const res = await request(`/dictionary/dictionary/getDictionaryList`, {
    method: 'POST',
    data: {
      code: 'FONT_FILE_CODE',
    },
  });
  const iconUrl = res?.dictionaryBody?.[0]?.description ?? '';
  return Promise.resolve({ iconUrl, statusCode: HttpCode.SUCCESS });
}
